var member_id = address_id = spage = ws = '';
document.addEventListener('plusready',function(){
	member_id = plus.storage.getItem('id');
	ws = plus.webview.currentWebview();
	address_id = ws.address_id;
	spage = ws.wsid;
	console.log(address_id);
	$.ajax({ 
		type:"post", 
		url:apiRoot+"?act=member_address&op=address_info",
		data:{address_id:address_id,member_id:member_id},
		dataType:'json',
		success:function(data){ 
			console.log(JSON.stringify(data));
			if(data.code == 200){
				$('.true_name').val(data.datas.address_info.true_name);
				$('.mob_phone').val(data.datas.address_info.mob_phone);
				$('.area_info').val(data.datas.address_info.area_info);
				$('.address').val(data.datas.address_info.address);
			}
		}, 
		error:function(e){
			toast('连接失败！');
		}
	});
},false);

function preservation(){
	var true_name = $('.true_name').val();
	var mob_phone = $('.mob_phone').val();
	var area_info = $('.area_info').val();
	var address = $('.address').val();
	if(!mob_phone.match(p1)){
		toast('请输入正确的联系电话!');return;
	}
	$.ajax({ 
		type:"post", 
		url:apiRoot+"?act=member_address&op=address_edit",
		data:{
			address_id:address_id,
			address:address,
			area_info:area_info,
			mob_phone:mob_phone,
			true_name:true_name,
			member_id:member_id
		},
		dataType:'json',
		success:function(data){ 
//				console.log(JSON.stringify(data)); 
			if(data.code == 200){
				toast('编辑成功！');
				plus.webview.getWebviewById(spage).reload();
				setTimeout(function(){
					ws.close()
				},1000);
			}else{
				toast(data.datas.error);
			}
		}, 
		error:function(e){
			toast('连接失败！');
		}
	});
}
